package lc.q151_200;

public class Q168 {

    public String convertToTitle(int columnNumber) {
//        String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        // 1对应A，26对应Z
        //
        // 是从1开始，不是从0开始
        StringBuilder sb = new StringBuilder();
        while (columnNumber > 0) {
            int k = (columnNumber - 1) % 26;
            char c = (char) ('A' + k);
            sb.insert(0, c);
            columnNumber = (columnNumber  - (columnNumber - 1) % 26) / 26;
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String s = new Q168().convertToTitle(701);
        System.out.println(s);
    }
}
